update metadata when a file item has wrong type in DB
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 21 Jan 2025 14:35:57 +0000 (15:35 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 22 Jan 2025 10:17:41 +0000 (11:17 +0100)
should help fixing the type of windows shortcuts in DB that were wrongly
set as virtual files

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/discovery.cpp

index 3b9785a62b32bb490b2ee9ad81bfa9d3080a14dc..831b85e334bb7219a27eb5390cc08672420bade7 100644 (file)
@@ -1679,6 +1679,18 @@ void ProcessDirectoryJob::processFileFinalize(
         item->_type = CSyncEnums::ItemTypeVirtualFileDehydration;
     }
 
+    if (item->_instruction != CSyncEnums::CSYNC_INSTRUCTION_NONE &&
+        !item->isDirectory() &&
+        _discoveryData->_syncOptions._vfs &&
+        _discoveryData->_syncOptions._vfs->mode() == OCC::Vfs::Off &&
+        (item->_type == CSyncEnums::ItemTypeVirtualFile ||
+         item->_type == CSyncEnums::ItemTypeVirtualFileDownload ||
+         item->_type == CSyncEnums::ItemTypeVirtualFileDehydration)) {
+        item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_UPDATE_METADATA;
+        item->_direction = SyncFileItem::Down;
+        item->_type = CSyncEnums::ItemTypeFile;
+    }
+
     if (path._original != path._target && (item->_instruction == CSYNC_INSTRUCTION_UPDATE_VFS_METADATA || item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA || item->_instruction == CSYNC_INSTRUCTION_NONE)) {
         ASSERT(_dirItem && _dirItem->_instruction == CSYNC_INSTRUCTION_RENAME);
         // This is because otherwise subitems are not updated!  (ideally renaming a directory could